Adding forms

Assumed that you already followed Install instructions, follow next steps to add forms to your app:

  1. Create a new dialog resource, no border, child styles, delete Ok and Cancel buttons.
  2. Arrange the controls you want to use with the table of your database
  3. Create the class with ClassWizard deriving the new form from CFormView.
  4. Add the OnInitialUpdate() message handler and the following code:(in the following example you access the fields IdCust and Name of the table Customers)
    OpenCursor( "SELECT * FROM [Customers]");
    AddEditCtrl( IDC_EDIT_ID, "IdCust", FLAG_EDIT_R_ONLY);
    AddEditCtrl( IDC_EDIT_NAME, "Name");
    CDBForm::OnInitialUpdate();
  5. Change the base class of the form from CFormView to CDBForm(see ADBWizard )
  6. Change the default constructor of the new class of the form from CFormView to CDBForm(see ADBWizard )
  7. Change the referring class of the message handler from CformView to CDBForm (see ADBWizard )
  8. Insert a new menu item in the main menu.
  9. Create the regular handler in the application.
  10. Make the header file of the new class available to the application.
  11. Insert the following code in it (assumed the new form is CformTest).
    OpenForm( RUNTIME_CLASS(CFormTest), "Title");
  12. Compile and link.

IMPORTANT: follow the previous steps in the right order or Class Wizard will generate a wrong message list.